<?php
	if (isset($_GET["ajax"])) {
		function __autoload($class_name){
			$dirs = array(
				'../../Factories/',
				'../../cntrlr/',
				'../../mdl/',
				'../../mdl/Delete/',
				'../../mdl/Select/',
				'../../mdl/Update/',
				'../../mdl/Insert/',
				'../../'
			);
			foreach($dirs as $dir){
				if(file_exists($dir.$class_name . '.php')){
					require_once($dir.$class_name . '.php');
					return;
				}
			}
			throw new BadFunctionCallException("No such Object file");
		}
	}
function takeCategories() {
	$factory = Factories::Init();
	$db = $factory->databaseObject("select","category");
	$array = $db->extractAll();
	$objects = array();

	foreach ($array as $val){
	 	$obj = $factory->controlerObject("Categories");
		$obj->Init($val);
	 	array_push($objects, $obj);
	 }
	 return $objects;
}

?>
